﻿#pragma once
#include "as_mysql_config.h"
#include <vector>
#include <mutex>
#include <condition_variable>
#include "thread_pool.h"

struct MYSQL;
namespace as
{
	namespace db
	{
		class MysqlConnection;
		class MysqlConnPool
		{
		public:
			enum
			{
				THREAD_COUNT = 1,
			};
			MysqlConnPool(const MysqlConnConfig& conf, int poolSize = 10);
			~MysqlConnPool();
			MysqlConnection* Pop();
		private:
			std::mutex lock_;
			std::vector<MysqlConnection*> pool_;
			MYSQL* conn_;
			std::atomic_bool is_stop_ = false;
		};
	}
}
